package com.yjtc.cbg.commonutildemo.TestUtil;

/**
 * Title: CommonUtilDemo
 * <p>
 * Description:
 * <p>
 * Author:baigege (baigegechen@gmail.com)
 * <p>
 * Date:2017-03-23
 */
public class Person {

    private String name;

    public Person(String name) {
        this.name = name;
    }

    public void sayHello(){
        synchronized (Person.class) {
            for (int i = 0; i < 3; i++) {
                try {
                    System.out.println(name + " say hello: " + i);
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public void sayWelcome(){
        for(int i=0;i<3;i++){
            try {
                System.out.println(name+" say Welcome: "+i);
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
